package generatorGraphics.graphics;

import java.awt.Color;
import java.awt.Dimension;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

public class Latency2 extends Graph {
    
    public Latency2(){
        name = "Latency";
        help = "Help of Latency";
        
        configUnitOptions();
    }
    
    private void configUnitOptions(){

        // Adicionando as unidades
        //--Não existe definição de Opções
        
        //Adicionando as opções
        //--Não existe definição de Opções
    }
    
    @Override
    protected void createGraph(String unit) {
        
        int indice;
        
//        if(search == null){
//            search = new SearchCommands(commands);
//            answer = (ArrayList<Object>) search.getCommandsAnswer();
//        }
        
        switch (unit){
            case "":
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                for(int j=0; j< 10; j++){
                    dataset.setValue(0.01 * j, 
                            "Latencia", "Id" + j);
                }
                JFreeChart chart = ChartFactory.createBarChart("Latencia nos ultimos " 
                        + "--" + " segundos",
                        "Dispositivos", "Latencia", dataset, 
                        PlotOrientation.VERTICAL, false, true, false);
                chart.setBackgroundImageAlpha(new Float(0.01));
                chart.setBackgroundPaint(new Color(238, 238, 238));
                
                CategoryPlot p = chart.getCategoryPlot();
                p.setBackgroundAlpha(new Float(0.01));
                p.setRangeGridlinePaint(Color.black);

                //Colocando em um painel do proprio swing java
                chartPanel = new ChartPanel(chart);
                chartPanel.setBackground(Color.LIGHT_GRAY);
                chartPanel.setPreferredSize(new Dimension(700, 350)); 
                chartPanel.setDomainZoomable(false);
                chartPanel.setRangeZoomable(false);
                
                break;
            default:
                
                break;
        }
    }
    
}
